/**
 * Index
 * @file 公用Anchor
 * @module src/pages/components/PolicyAnchor/index.tsx
 * @author yunqilaohe
 */

import React from 'react';
import { Radio, Space } from 'antd';
import { RadioGroupProps } from 'antd/lib/radio/interface';
import { RadioButtonProps } from 'antd/lib/radio/radioButton';
import styles from './index.less';

interface DataSourceState extends RadioButtonProps {
  title: string;
  code: string | number;
}

interface PolicyAnchorProps extends RadioGroupProps {
  direction?: 'horizontal' | 'vertical';
  dataSource: DataSourceState[];
}

const PolicyRadio = (props: PolicyAnchorProps): React.ReactElement => {
  const { direction = 'vertical', dataSource } = props;
  return (
    <Radio.Group {...props}>
      <Space size={0} direction={direction}>
        {dataSource.map((item, index) => {
          return (
            <Radio.Button key={index} className={styles.radioButton} value={item.code} {...item}>
              <div className={styles.radioText}>
                <div style={{ paddingRight: 10, paddingBottom: 2, fontSize: 30 }}>·</div>
                <div></div>
                <div>{item.title}</div>
              </div>
            </Radio.Button>
          );
        })}
      </Space>
    </Radio.Group>
  );
};

export default PolicyRadio;
